package clazzobject;

class Person {

    private String name;
    private String gender;
    private String birthday;

    public Person() {
    }

    public Person(String name, String gender, String birthday) {
        this.name = name;
        this.gender = gender;
        this.birthday = birthday;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", gender='" + gender + '\'' +
                ", birthday='" + birthday + '\'' +
                '}';
    }
}

public class GetClazzObjectDemo {

    public static void main(String[] args) throws Exception {
        //1.使用Class.forName
        Class clazz1 = Class.forName("clazzobject.Person");
        //2.使用对象.getClass();
        Person p = new Person();
        Class clazz2 = p.getClass();
        //3.使用类名.class
        Class clazz3 = Person.class;

        System.out.println(clazz1.getName());
        System.out.println(clazz1 == clazz2);
        System.out.println(clazz2 == clazz3);
    }
}
